<template>
  <div class="error_container">
    <div class="content">
      <span class="code">{{ code }}</span>
      <span class="message">{{ message }}</span>
      <router-link to="/home">
        <a-button type="primary" size="large">返回首页</a-button>
      </router-link>
    </div>
  </div>
</template>

<script>
import { computed, defineComponent, reactive, toRefs } from 'vue'
import { useRoute } from 'vue-router'

export default defineComponent({
  setup () {
    const route = useRoute()
    const state = reactive({
      code: route.params.code,
      message: computed(() => {
        switch (state.code) {
          case '403':
            return '权限不足'
          case '404':
            return '非常抱歉，没有找到您要访问的页面'
          case '500':
          default:
            return '信号受到干扰'
        }
      })
    })

    return {
      ...toRefs(state)
    }
  }
})
</script>

<style lang="less" scoped>
.error_container {
  background-color: #00000010;
  width: 100%;
  height: 100%;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;

  & .content {
    width: 550px;
    height: 400px;
    padding: 60px 0;
    background-color: #ffffff;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-around;

    & .code {
      font-size: 80px;
      font-weight: bolder;
    }

    & .message {
      font-size: 25px;
    }
  }
}
</style>
